package com.jlastu.androiduidemo.bean;


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*import com.example.yixueguan.database.MyDBHelper;*/
import com.jlastu.androiduidemo.database.MyDBHelper;
public class StudentXJ {
    private Context context;
    private MyDBHelper dbHelper;
    private SQLiteDatabase db;

    //构造函数
    public StudentXJ(Context context) {
        this.context = context;
    }

    //打开数据库
    public void open() throws SQLiteException {
        dbHelper = new MyDBHelper(context);
        try {
            db = dbHelper.getWritableDatabase();
        } catch (SQLiteException ex) {
            db = dbHelper.getReadableDatabase();
        }
    }

    //关闭数据库
    public void close() {
        if (db != null) {
            db.close();
            db = null;
        }
    }

    //添加学生信息
    public long addStudents(Student o) {
        // 创建ContentValues对象
        ContentValues values = new ContentValues();
        // 向该对象中插入键值对
/*
        values.put("studentid", o.studentid);
        values.put("studentname", o.studentname);
        values.put("majoy", o.majoy);
        values.put("studentclass", o.studentclass);
*/

        // 调用insert()方法将数据插入到数据库当中
        return db.insert("tb_Students", null, values);
    }
}